<template>
	<view class="manageBank">
		<view class="cell">
			<view>
				{{name}}
			</view>
			<view @click="delTip" class="red">
				解除绑定
				</view>
		</view>
	</view>
</template>

<script>
var util = require('../../../common/util.js');
export default {
    data() {
        return {
            name: '',
            id: 0
        };
    },
    onLoad(e) {
        console.log(e);
        this.name = e.name;
        this.id = e.id;
    },
    methods: {
        delTip() {
            uni.showModal({
                // title: '确认删除该地址吗？',
                content: '确认解绑吗',
                cancelText: '确定',
                cancelColor: '#cccccc',
                confirmText: '再想想',
                confirmColor: '#fff',
                success: res => {
                    if (res.confirm) {
                    } else if (res.cancel) {
                        this.delBank();
                    }
                },
                fail: () => {},
                complete: () => {}
            });
        },

        delBank() {
            util.ajax(
                'userBankDel',
                {
                    targetId: this.id,
                    token: util.getUserToken()
                },
                data => {
                    let json = data.data;
                    if (json.status) {
						uni.showToast({
							title: '解绑成功',
							icon: 'none',
							duration: 600
						});
						setTimeout(()=>{
							uni.navigateBack({
								delta: 1
							});
						},600)
                       
                    } else {
                        uni.showToast({
                            title: json.message,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                },
                (data, code) => {
                    // console.log(data);
                    uni.showToast({
                        title: JSON.stringify(data.message),
                        icon: 'none',
                        duration: 1000
                    });
                }
            );
        }
    }
};
</script>

<style lang="less">
.manageBank {
    width: 100%;
    .cell {
        width: 100%;
        background: white;
        height: 90upx;
        padding: 0 30upx;
        justify-content: space-between;
        view {
            align-items: center;
        }
        .red {
            color: red;
        }
    }
}
</style>
